/**
* 版权声明：厦门睿商网络科技有限公司 版权所有 违者必究
* 日    期：2020-08-28
*/
package com.rzico.market.entity;

import com.rzico.annotation.IgnoreSwaggerParameter;
import com.rzico.basics.entity.Supplier;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

/**
 * <pre>
 *   开票商品信息数据库对象
 * </pre>
 * @author Rzico Boot
 * @version 1.0
 */
@Data
@JsonIgnoreProperties(value = {"handler"})
@JsonInclude(JsonInclude.Include.NON_NULL)
@Table(name = "mk_market_invoice")
public class Invoice{
    @Id
    @ApiModelProperty(value = "" )
    protected Long id;

    @ApiModelProperty(value = "创建日期" )
    protected Date createDate;

    @ApiModelProperty(value = "修改日期" )
    protected Date modifyDate;

    @JsonIgnore
    @ApiModelProperty(value = "是否删除" ,hidden = true )
    protected Boolean deleted;

    @ApiModelProperty(value = "开票状态(0:未开票,1:已完成)" )
    protected Boolean state;

    @ApiModelProperty(value = "运营发货时间" )
    protected Date shippingDate;

    @ApiModelProperty(value = "供应商发货时间" )
    protected Date sendDate;

    @ApiModelProperty(value = "完成时间" )
    protected Date completeDate;

    @ApiModelProperty(value = "来源订单" )
    protected Long orderId;

    @ApiModelProperty(value = "订单号" )
    protected String orderSn;

    @ApiModelProperty(value = "送货单ID" )
    protected Long shippingId;

    @ApiModelProperty(value = "送货单单项ID" )
    protected Long shippingItemId;

    @ApiModelProperty(value = "送货单编号" )
    protected String shippingSn;

    @ApiModelProperty(value = "买方会员" )
    protected Long memberId;

    @ApiModelProperty(value = "供应商(空为本部，若为京东供应商填与之相关的信息)" )
    protected Long supplierId;

    @ApiModelProperty(value = "是否退货" )
    protected Boolean isReturn;

    @ApiModelProperty(value = "产品编号" )
    protected Long productId;

    @ApiModelProperty(value = "条码/货号" )
    protected String productSn;

    @ApiModelProperty(value = "商品名称" )
    protected String productName;

    @ApiModelProperty(value = "单位" )
    protected String productUnit;

    @ApiModelProperty(value = "商品结算成本" )
    protected BigDecimal productCost;

    @ApiModelProperty(value = "商品价格" )
    protected BigDecimal productPrice;

    @ApiModelProperty(value = "商品总金额")
    protected BigDecimal subPrice;

    @ApiModelProperty(value = "数量" )
    protected BigDecimal productQuantity;

    @ApiModelProperty(value = "已开票数量" )
    protected BigDecimal inInvoiceQuantity;

    @ApiModelProperty(value = "归属企业" )
    protected Long enterpriseId;

    @JsonIgnore
    @ApiModelProperty(value = "创建者" ,hidden = true )
    protected String createBy;

    @JsonIgnore
    @ApiModelProperty(value = "更新者" ,hidden = true )
    protected String modifyBy;

    @ApiModelProperty(value = "商品支付明细")
    List<InvoiceItem> itemList = Collections.emptyList();;

    /**
     *  供应商
     */
    @JsonIgnore
    @IgnoreSwaggerParameter
    protected Supplier supplier;

    public String getSupplierName() {
        Supplier supplier = getSupplier();
        if (supplier!=null) {
            return supplier.getName();
        } else {
            return null;
        }
    }

}
